Add SRT MPEG-TS ingest with fMP4 repackaging and MoQ object publishing. - #14
Merged
Conversation
TilsonJoji
marked this pull request as ready for review
June 3, 2026 10:34
- annexb_to_avcc: add missing end-of-buffer fixup so the final NAL unit in each call is not truncated by 3 bytes; mirrors the identical guard already present in extract_nal_units() - build_hvcc_box: tighten sps_payload_size guard from < 12 to < 13; general_level_idc is read at sps_data[12] which requires size >= 13 - Video dimensions: replace hardcoded 1920x1080 placeholder with actual values parsed from the first keyframe SPS. Adds RbspBitReader, parse_h264_dimensions() (full RBSP including high-profile scaling lists, POC, frame cropping), and parse_hevc_dimensions() (full profile_tier_level, conformance window). Results are stored under discovery mutex alongside codec_private so the rebuilt init segment carries correct tkhd/stsd dimensions for any resolution.
base_pts90k is set from the first published sample. When a subsequent sample arrives with a lower PTS the offset was silently clamped to 0, producing tfdt=0 in the moof. Two scenarios trigger this: - Small underflow (audio pre-roll / jitter): one or two frames at t=0 is harmless; keep the zero-clamp for this case. - 33-bit PTS rollover (~26.5 h): sample.pts90k wraps from near 2^33 back to zero while base_pts90k remains large, so every subsequent sample gets tfdt=0 and the decoder timeline collapses permanently. Fix: if the backward jump exceeds 2^32 ticks (~13 h, impossible as normal jitter) treat it as a rollover and reset base_pts90k to the new PTS. Duration tracking recovers naturally on the next frame via the existing last_pts / 500 ms clamp logic.
annexb_to_avcc: skip zero-length NAL units produced when two start codes are adjacent (nal_size=0). Without this, a zero-length BE32 prefix is emitted and the decoder misreads the following bytes as NAL data, corrupting the rest of the AVCC stream. On skip, the outer loop resumes from the same position and correctly finds the next start code. SRT drain_queue: move finish_group loop before the error-path return so subgroup streams opened with fin=false are always closed, even when drain_queue fails mid-batch. The original status is preserved: a finish_group failure only updates status when it was previously clean. creation_time_us: stamp each fragment with the wall-clock time at build time so queue-delay metrics produce meaningful values instead of always reading zero.
…PTS offsets for each moof. With live SRT ingest, PTS can have small jitter, which can produce non-monotonic decode times. The MSE adapter then sees overlapping media ranges and drops payloads.Switched back to the accumulation-based timeline. For each track, the next base_decode_time is derived from the previous sample’s decode time plus its sample duration. This guarantees monotonic tfdt values even when raw PTS has small jitter.Since the encoder is configured with no B-frames, there is no decode reordering concern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is PR that adds SRT live ingest support to the publisher.
It allows the publisher to receive MPEG-TS over SRT, parse the incoming transport stream, extract audio/video samples, repackage them into fragmented MP4 media objects, and publish them as MoQ objects.
Key changes
moof+mdatmedia fragments from the extracted samples.stdinorsrt, not both at the same time.Notes